/*
 * Copyright (c) 2011, Brookhaven National Laboratory
 * All rights reserved.
 * The software in this package is published under the terms
 * of the BSD license a copy of which has been included with
 * this distribution in the license.txt file.
 */

#include <dds/core/Exception.hpp>
#include <dds/xtypes/TypeObject.hpp>

#include <tdds/xtypes/DynamicType.hpp>
#include "dds/type/dynamic/detail/DynamicType.h"

#include "dds/type/dynamic/detail/Descriptor.h"

#include "oxtypes/delegate/DynamicType.h"

typedef dds::type::dynamic::detail::AnnotationDescriptor AD;
typedef dds::type::dynamic::detail::MemberDescriptor MD;
typedef dds::type::dynamic::detail::TypeDescriptor TD;

namespace tdds { namespace type { namespace dynamic {

// Annotation Descriptor

template <> dds::type::dynamic::DynamicType
AnnotationDescriptor <AD>::type() const{
  return d_.type;
}

template <> void 
AnnotationDescriptor <AD>::type(const dds::type::dynamic::DynamicType& value){
  d_.type = value;
}

template <> const std::string 
AnnotationDescriptor <AD>::value(const std::string& key) {
  throw dds::core::UnsupportedError("");
}

template <> void 
AnnotationDescriptor <AD>::value(const std::string& key, 
				 const std::string& value){
  throw dds::core::UnsupportedError("");
}

template <> const dds::type::dynamic::Parameters 
AnnotationDescriptor <AD>::all_values() const {
  throw dds::core::UnsupportedError("");
}

template <> dds::type::dynamic::Parameters&
AnnotationDescriptor <AD>::all_values(dds::type::dynamic::Parameters& dst) const {
  throw dds::core::UnsupportedError("");
}

template <> bool 
AnnotationDescriptor <AD>::is_consistent() const {
  throw dds::core::UnsupportedError("");
}

// Member Descriptor

template <> const std::string 
MemberDescriptor <MD>::name() const {
  return d_.name;
}
    

template <> void 
MemberDescriptor <MD>::name(const std::string& value) {
  d_.name = value;
}

template <> dds::type::MemberId 
MemberDescriptor <MD>::id() const {
  return d_.id;
}
    
template <> void 
MemberDescriptor <MD>::id(dds::type::MemberId value){
  d_.id = value;
}

template <> dds::type::dynamic::DynamicType 
MemberDescriptor <MD>::type() const {
  return d_.type;
}
    
template <> void
MemberDescriptor <MD>::type(const dds::type::dynamic::DynamicType& value) {
  d_.type = value;
}

template <> const std::string 
MemberDescriptor <MD>::default_value() const {
  return d_.defaultValue;
}

template <> void 
MemberDescriptor <MD>::default_value(const std::string& value) {
  d_.defaultValue = value;
}

template <> uint32_t 
MemberDescriptor <MD>::index() const {
  return d_.index;
}
    
template <> void 
MemberDescriptor <MD>::index(uint32_t value) {
  d_.index = value;
}

template <> const dds::type::UnionCaseLabelSeq 
MemberDescriptor <MD>::label() const {
  throw dds::core::UnsupportedError("");
}

template <> dds::type::UnionCaseLabelSeq&
MemberDescriptor <MD>::label(dds::type::UnionCaseLabelSeq& dst) const {
  throw dds::core::UnsupportedError("");
}

template <> void 
MemberDescriptor <MD>::label(const dds::type::UnionCaseLabelSeq& value) {
  throw dds::core::UnsupportedError("");
}

template <> bool 
MemberDescriptor <MD>::default_label() {
  return d_.defaultLabel;
}
    
template <> void 
MemberDescriptor <MD>::default_label(bool value) {
  d_.defaultLabel = value;
}

template <> bool 
MemberDescriptor <MD>::is_consistent() {
  throw dds::core::UnsupportedError(""); 
}

// Type Descriptor 

template <> dds::type::TypeKind 
TypeDescriptor <TD>::kind() const {
  return d_.typeKind;
}

template <> void 
TypeDescriptor <TD>::kind(dds::type::TypeKind value) {
  d_.typeKind = value;
}

template <> const std::string 
TypeDescriptor <TD>::name() const {
  return d_.name;
}
    
template <> void 
TypeDescriptor <TD>::name(const std::string& value) {
  d_.name = value;
}

template <> dds::type::dynamic::DynamicType 
TypeDescriptor <TD>::base_type() const {
  return d_.baseType;
}
    
template <> void 
TypeDescriptor <TD>::base_type(const dds::type::dynamic::DynamicType& value) {
  d_.baseType = value;
}

template <> dds::type::dynamic::DynamicType 
TypeDescriptor <TD>::discriminator_type() const {
  return d_.discType;
}

template <> void 
TypeDescriptor <TD>::discriminator_type(
  const dds::type::dynamic::DynamicType& value) {
  d_.discType = value;
}

template <> const dds::type::BoundSeq 
TypeDescriptor <TD>::bound() const {
  throw dds::core::UnsupportedError(""); 
}
    
template <> dds::type::BoundSeq& 
TypeDescriptor <TD>::bound(dds::type::BoundSeq& dst) const {
    throw dds::core::UnsupportedError(""); 
}

template <> void 
TypeDescriptor <TD>::bound(const dds::type::BoundSeq& value) {
  throw dds::core::UnsupportedError(""); 
}

template <> dds::type::dynamic::DynamicType 
TypeDescriptor <TD>::element_type() const {
  return d_.elemType;
}
    
template <> void 
TypeDescriptor <TD>::element_type(const dds::type::dynamic::DynamicType& value) {
  d_.elemType = value;
}

template <> dds::type::dynamic::DynamicType 
TypeDescriptor <TD>::key_element_type() const {
  return d_.keyType;
}
    
template <> void 
TypeDescriptor <TD>::key_element_type(
    const dds::type::dynamic::DynamicType& value) {
  d_.keyType = value;
}

template <> bool 
TypeDescriptor <TD>::is_consistent() const {
  throw dds::core::UnsupportedError(""); 
}

}}}
